home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / New System Software Extensions / QuickDraw™ GX 1.1.2 / Programming Stuff / Development & Debugging Tools / Virtual User scripts / GX Printer Test Suites / Main.lib next >
Encoding:
Text File  |  1995-04-10  |  13.8 KB  |  494 lines  |  [TEXT/MPS ]

  1. ##################################################################################################################
  2. ##     General LaserWriter GX printing test library for Virtual User test environment                                ##
  3. ##################################################################################################################
  4. ##            Developed by Brad Reigel and Scott Cutler, Apple Computer, Inc.                                        ##
  5. ##################################################################################################################
  6. ##            Last Modified July 19, 1994                                                                            ##
  7. ##################################################################################################################
  8.  
  9. ##    Initializate assumes the folowing:
  10. ##        a folder name "Documents" is open on the Desktop.
  11. ##        documents to be tested reside in the above folder.
  12.  
  13. task Initialize()
  14. begin
  15.     type k: { uparrowKey };                                                ##    selects the first most document in window
  16.     println "#   Opening document…";
  17.     pressKey k: { commandKey };
  18.     type k: { 'O' };                                                    ##    Command - O
  19.     releaseKey k: { commandKey };
  20.     println "#   Synchronizing…";
  21.     results := PrintingEnabled();                                        ##    determine if Print Item is enabled
  22.     while not (results)                                                    ##    if true
  23.     results := PrintingEnabled();                                        ##    determine if Print Item is enabled
  24. end;
  25.  
  26. ##  OpenAndPrintInitialize
  27. ##        Opens document from finder and waits for print menu item to become active.
  28. ##        WARNING:  Some applications (esp Claris) make this item active before the document
  29. ##        has actually finished opening.
  30.  
  31. task OpenAndPrintInitialize()
  32. begin
  33.     println "#   Opening document…";
  34.     pressKey k: { commandKey };
  35.     type k: { 'O' };                                                    ##    Command - O
  36.     releaseKey k: { commandKey };
  37.     println "#   Synchronizing…";
  38.     results := PrintingEnabled();                                        ##    determine if Print Item is enabled
  39.     while not (results)                                                    ##    if true
  40.     results := PrintingEnabled();                                        ##    determine if Print Item is enabled
  41. end;
  42.  
  43. ##    LoadNextDocument
  44. ##        Gets next document.
  45.  
  46. task LoadNextDocument()
  47. begin
  48.     type k: { downarrowKey };
  49.     println "#   Opening document…";
  50.     pressKey k: { commandKey };
  51.     type k: { 'O' };                                                    ##    Command - O
  52.     releaseKey k: { commandKey };
  53.     println "#   Synchronizing…";
  54.     results := PrintingEnabled();                                        ##    determine if Print Item is enabled
  55.     while not (results)                                                    ##    if true
  56.     results := PrintingEnabled();                                        ##    determine if Print Item is enabled
  57. end;
  58.  
  59. ##    Printing Enabled
  60. ##        Checks to see if the Print menu item is enabled for selection.  Returns true if Print is enabled.
  61. ##        Returns false if Print is not enabled.
  62.  
  63. task PrintingEnabled()
  64. begin
  65.     match [menuItem t:/Print/ e:?PrintEnabled m:"File"];
  66.     if (PrintEnabled)
  67.         return true;
  68.     else
  69.         return false;
  70. end;
  71.  
  72. ##    SetPaper
  73. ##        Accepts a string value and selects the appropriate radioButton.
  74. ##        String: US Letter/US Legal/A4 Letter/B5 Letter/Tabloid (11x17)/Custom.
  75.  
  76. task SetPaper(kPaper)
  77. begin
  78.     if match [radioButton t:kPaper]
  79.         begin
  80.             select [radioButton t:kPaper]!;
  81.             println "#      Paper -> ",kPaper;
  82.         end;
  83. end;
  84.  
  85. ##    SetOrientation
  86. ##        Selects the appropriate icon for Portrait or Landscape orientation.
  87.  
  88. task SetOrientation(kOrientation)
  89. begin
  90.     match [window o:1 r:?portBounds];
  91.     if (kOrientation = "Portrait")
  92.         begin
  93.             move a: { portBounds[1] + 115, portBounds[2] + 120 };
  94.             click;
  95.             println "#      Orientation -> ",kOrientation;
  96.         end;
  97.     else
  98.         begin
  99.             move a: { portBounds[1] + 155, portBounds[2] + 120 };
  100.             click;
  101.             println "#      Orientation -> ",kOrientation;
  102.         end;
  103. end;
  104.  
  105. ##    SetScale
  106. ##        Accepts a numeric value and types the value.
  107.  
  108. task SetScale(kScale)
  109. begin
  110.     match [window o:1 r:?portBounds];
  111.     move a: { portBounds[1] + 300, portBounds[2] + 117 };
  112.     doubleClick;
  113.     type k: { kScale };
  114.     println "#      Scale -> ",kScale;
  115. end;
  116.  
  117. ##    SetCopies
  118. ##        Accepts a numeric value and types the value.
  119.  
  120. task SetCopies(kCopies)
  121. begin
  122.     if (kCopies > 1)
  123.         begin
  124.             type k: { kCopies };
  125.             println "#      Copies -> ",kCopies;
  126.         end;
  127.     else
  128.         println "#      Copies -> 1";
  129. end;
  130.  
  131. ##    SetPages
  132. ##        Accepts a string and selects the appropriate radioButton.  String: All/From 
  133. ##        If string is From, two numeric value must be passed in.
  134.  
  135. task SetPages(kPages, kFrom, kTo)
  136. begin
  137.     if (kPages = "All")
  138.         begin
  139.             match [window o:1 r:?portBounds];
  140.             move a: { portBounds[1] + 202, portBounds[2] + 47 };
  141.             click;
  142.         end;
  143.     else
  144.         begin
  145.             match [window o:1 r:?portBounds];
  146.             select [radioButton t:"From:"]!;
  147.             move a: { portBounds[1] + 325, portBounds[2] + 44 };
  148.             click;
  149.             type k: { kFrom };
  150.             println "#         From -> ",kFrom;
  151.             type k: { tabKey };
  152.             type k: { kTo };
  153.             println "#         To -> ",kTo;
  154.         end;
  155. end;
  156.  
  157. ##    SetCoverPage
  158. ##        Accepts a string and selects the appropriate radioButton.  String: No/First Page/Last Page
  159.  
  160. task SetCoverPage(kCoverPage)
  161. begin
  162.     match [radioButton t:kCoverPage];  ## is this needed?
  163.     if (kCoverPage = "No")
  164.         begin
  165.             select [radioButton t:"No"]!;
  166.             println "#      Cover Page -> ",kCoverPage;
  167.         end;
  168.     else if (kCoverPage = "First Page")
  169.         begin
  170.             select [radioButton t:"First Page"]!;
  171.             println "#      Cover Page -> ",kCoverPage;
  172.         end;
  173.     else if (kCoverPage = "Last Page")
  174.         begin
  175.             select [radioButton t:"Last Page"]!;
  176.             println "#      Cover Page -> ",kCoverPage;
  177.         end;
  178. end;
  179.  
  180. ##    SetPaperSource
  181. ##        Sets Paper Source to default value "Paper Cassette".
  182.  
  183. task SetPaperSource(kPaperSource := "Paper Cassette")
  184. begin
  185.     if (kPaperSource = "Paper Cassette")
  186.         begin
  187.             select [radioButton t:"Paper Cassette"]!;
  188.             println "#      Paper Source -> ",kPaperSource;
  189.         end;
  190.     else
  191.         begin
  192.             select [radioButton t:"Manual Feed"]!;
  193.             println "#      Paper Source -> ",kPaperSource;
  194.         end;
  195. end;
  196.  
  197. ##    SetPrintPreview
  198. ##        Sets Print Preview to value passed.
  199.  
  200. task SetPrintPreview(kPrintPreview)
  201. begin
  202.     match [checkBox t:"Print Preview" s:?checked];
  203.     if (kPrintPreview = true) and (checked[1] = 0)
  204.         begin
  205.             select [checkBox t:"Print Preview"]!;
  206.             println "#      Print Preview -> ",kPrintPreview;
  207.         end;
  208.     else if (kPrintPreview = false) and (checked[1] = 1)
  209.         begin
  210.             select [checkBox t:"Print Preview"]!;
  211.             println "#      Print Preview -> ",kPrintPreview;
  212.         end;
  213. end;
  214.  
  215. ##    SetPrintUsingColor
  216. ##        If kPrintUsingColor = "true", then prints color, else prints black & white.
  217. ##        Works in applications with a "Print Using Color" checkbox in print dialog.
  218.  
  219. task SetPrintUsingColor(kPrintUsingColor)
  220. begin
  221.     match [checkBox t:"Print Using Color" s:?checked];
  222.     if (kPrintUsingColor = true) and (checked[1] = 0)
  223.         begin
  224.             select [checkBox t:"Print Using Color"]!;
  225.             println "#      Print Usinf Color -> ",kPrintUsingColor;
  226.         end;
  227.     else if (kPrintUsingColor = false) and (checked[1] = 1)
  228.         begin
  229.             select [checkBox t:"Print Using Color"]!;
  230.             println "#      Print Usinf Color -> ",kPrintUsingColor;
  231.         end;
  232. end;
  233.  
  234. ##    SetDestination
  235. ##        Accepts four strings:
  236. ##            The first string is destination. String: Printer/Disk File.
  237. ##            The second string is file name.  String: determined by scriptor.
  238. ##            The third string is file format.  Boolean: true = Print File/false = PostScript®.
  239. ##            The fourth string is include fonts.  Boolean: true = No Fonts/false = Fonts
  240.  
  241. task SetDestination(kDestination, kName, kFormat, kFonts)
  242. begin
  243.     if (kDestination = "Printer")
  244.         begin
  245.             select [radioButton t:"Printer"];
  246.             println "#      Destination -> ",kDestination;
  247.         end;
  248.     else
  249.         begin
  250.             select [radioButton t:"Disk File"];
  251.             println "#      Destination -> ",kDestination;
  252.             type k: { returnKey };
  253.             type k: { kName };
  254.             println "#         File Name -> ",kName;
  255.             if (kFormat = false)
  256.                 begin
  257.                     match [window o:1 r:?portBounds];
  258.                     move a: { portBounds[1] + 226, portBounds[2] + 213 };
  259.                     pressMouse;
  260.                     move r: { 0, 15 };
  261.                     wait(1);
  262.                     releaseMouse;
  263.                     println "#         Format -> PostScript®";
  264.                 end;
  265.             else
  266.                 println "#         Format -> Print File";
  267.             if (kFonts = true)
  268.                 begin
  269.                     wait(2);
  270.                     select [checkBox t:"Don∂'t include fonts in file"];
  271.                     println "#         Don’t include fonts in file -> ",kFonts;
  272.                 end;
  273.             else
  274.                 println "#         Don’t include fonts in file -> ",kFonts;
  275.             SaveInFolder( "Disk Files" );
  276.         end;
  277.     type k: { returnKey };
  278. end;
  279.  
  280. ##    DialogPresent
  281. ##        Checks the frontmost window and returns true if is a dialog.  If window is not
  282. ##        a dialog, return false.
  283.  
  284. task DialogPresent()
  285. begin
  286.     wait(15);
  287.     match [window o:1 s:?windowStyle];
  288.     if (windowStyle = dialog)
  289.         return true;
  290.     else if (windowStyle = movablemodal)
  291.         return true;
  292.     else if (windowStyle = shadow)
  293.         return true;
  294.     else
  295.         return false;
  296. end;
  297.  
  298. ##  SetOptions
  299. ##        Sets options in the options dialog depending on values passed in.
  300. ##        Options dialog from Print dialog must be open when calling SetOptions.
  301.  
  302. task SetOptions(kFlipHorz, kFlipVert, kInvertImage, kPrecisionBitmap)
  303. begin
  304.  
  305.     ### Flip Horizontal        
  306.     match [checkBox t:"Flip Horizontal" s:?kHorzChecked];
  307.     wait(1);
  308.     if (kFlipHorz = true) and (kHorzChecked[1] = 0)
  309.         select [checkBox t:"Flip Horizontal"]!;
  310.     else if (kFlipHorz = false) and (kHorzChecked[1] = 1)
  311.         select [checkBox t:"Flip Horizontal"]!;
  312.     println "#      Flip Horizontal -> ",kFlipHorz;
  313.  
  314.     ### Flip Vertical        
  315.     match [checkBox t:"Flip Vertical" s:?kVertChecked];
  316.     wait(1);
  317.     if (kFlipVert = true) and (kVertChecked[1] = 0)
  318.         select [checkBox t:"Flip Vertical"]!;
  319.     else if (kFlipVert = false) and (kVertChecked[1] = 1)
  320.         select [checkBox t:"Flip Vertical"]!;
  321.     println "#      Flip Vertical -> ",kFlipVert;
  322.  
  323.     ### Invert Image        
  324.     match [checkBox t:"Invert Image" s:?kInvertImageChecked];
  325.     wait(1);    
  326.     if (kInvertImage = true) and (kInvertImageChecked[1] = 0)
  327.         select [checkBox t:"Invert Image"]!;
  328.     else if (kInvertImage = false) and (kInvertImageChecked[1] = 1)
  329.         select [checkBox t:"Invert Image"]!;
  330.     println "#      Invert Image -> ",kInvertImage;
  331.  
  332.     ### Precision Bitmap Alingment        
  333.     match [checkBox t:/Precision Bitmap Alignment/ s:?kBitMapChecked];
  334.     wait(1);
  335.     if (kPrecisionBitmap = true) and (kBitMapChecked[1] = 0)
  336.         select [checkBox t:/Precision Bitmap Alignment/];
  337.     else if (kPrecisionBitmap = false) and (kBitMapChecked[1] = 1)
  338.         select [checkBox t:/Precision Bitmap Alignment/];
  339.     println "#      Precision Bitmap Alingment -> ",kPrecisionBitmap;
  340.  
  341.     type k: { returnKey };
  342. end;
  343.  
  344. ##  SetPrintColorBitmap
  345. ##        Prints using color bitmap, depending upon value passed in.
  346. ##        Works in applications with a "Color" radio button in Print dialog.
  347.  
  348. task SetPrintColorBitmap(kPrintColorBitmap)
  349. begin
  350.     match [radioButton t:"Color" s:?enabled];
  351.     if (kPrintColorBitmap = true) and (enabled[1] = 0)
  352.         begin
  353.             select [radioButton t:"Color"];
  354.             println "#      Print Color Bitmap -> Color";
  355.         end;
  356.     else if (kPrintColorBitmap = false) and (enabled[1] = 1)
  357.         begin
  358.             select [radioButton t:"Gray (Faster)"];
  359.             println "#      Print Color Bitmap -> Gray (Faster)";
  360.         end;
  361. end;
  362.  
  363. ##  SetFractionalWidths
  364. ##        Sets fractional widths option for text
  365.  
  366. task SetFractionalWidths(kFractionalWidths)
  367. begin
  368.     match [checkBox t:"Fractional Widths" s:?checked];
  369.     if (kFractionalWidths = true) and (checked[1] = 0)
  370.         select [checkBox t:"Fractional Widths"]!;
  371.     else if (kFractionalWidths = false) and (checked[1] = 1)
  372.         select [checkBox t:"Fractional Widths"]!;
  373. end;
  374.  
  375. task SetUseAsDefault(kUseAsDefault)
  376. begin
  377.     match [checkBox t:"Use As Default" s:?checked];
  378.     if (kUseAsDefault = true) and (checked[1] = 0)
  379.         select [checkBox t:"Use As Default"]!;
  380.     else if (kUseAsDefault = false) and (checked[1] = 1)
  381.         select [checkBox t:"Use As Default"]!;
  382. end;
  383.  
  384. task SetPrintPostScriptOverText(kPrintPostScriptOverText)
  385. begin
  386.     match [checkBox t:"Print PostScript Over Text" s:?checked];
  387.     if (kPrintPostScriptOverText = true) and (checked[1] = 0)
  388.         select [checkBox t:"Print PostScript Over Text"]!;
  389.     else if (kPrintPostScriptOverText = false) and (checked[1] = 1)
  390.         select [checkBox t:"Print PostScript Over Text"]!;
  391. end;
  392.  
  393. ## Options are All, Odd Pages Only and Even Pages Only
  394. task SetPrintPages(kPrintPages := "All")
  395. begin
  396.     if (kPrintPages <> "All")
  397.         select [radioButton t:kPrintPages]!;
  398.     else
  399.         begin
  400.             match [window o:1 r:?portBounds];
  401.             move a: { portBounds[1] + 161, portBounds[2] + 143 };
  402.             click;
  403.         end;
  404. end;
  405.  
  406. ##  Quit
  407. ##        Quits open application, pressing default key in "save document?" query dialog.
  408.  
  409. task Quit()
  410. begin
  411.     println "# Quiting…";
  412.     select [menuItem t:"Quit" m:"File"];
  413.     wait(2);
  414.     if (DialogPresent())
  415.         begin
  416.             type k: { returnKey };
  417.             println "#   Saving…";
  418.         end;
  419.     else
  420.         println "#   No quit dialog appeared";
  421. end;
  422.  
  423. ##  SaveInFolder
  424. ##        Saves files (such as PostScript) in the given folder located on the desktop.
  425.  
  426. task SaveInFolder(kFolderName)
  427. begin
  428.     select [button t:"Desktop"];
  429.     type k: { tabKey };
  430.     type k: { kFolderName };
  431.     type k: { returnKey };
  432. end;
  433.  
  434. ##  DialogAction
  435. ##        Presses button named kButtonName in frontmost dialog.
  436.  
  437. task DialogAction(kButtonName)
  438. begin        
  439.     if (kButtonName = "Default")
  440.         type k: { returnKey };
  441.     else if (kButtonName = "OK")
  442.         if (match [button t:"OK"])
  443.             select [button t:"OK"];
  444.     else if (kButtonName = "Cancel")
  445.         if (match [button t:"Cancel"])
  446.             select [button t: "Cancel"];
  447.     println "#  Dialog -> ", kButtonName;
  448. end;
  449.  
  450. ##  SetLWSCOrientation
  451. ##        Sets orientation in Page Setup dialog for LWIISC driver.
  452.  
  453. task SetLWSCOrientation(kOrientation)
  454. begin
  455.     match [window o:1 r:?portBounds];
  456.     if (kOrientation = "Portrait")
  457.         begin
  458.             move a: { portBounds[1] + 45, portBounds[2] + 130 };
  459.             click;
  460.             println "#      Orientation -> ",kOrientation;
  461.         end;
  462.     else
  463.         begin
  464.             move a: { portBounds[1] + 80, portBounds[2] + 130 };
  465.             click;
  466.             println "#      Orientation -> ",kOrientation;
  467.         end;
  468. end;
  469.  
  470. ##  SetLWSCScale
  471. ##        Sets scale in Page Setup dialog for LWIISC driver.
  472.  
  473. task SetLWSCScale(kScale)
  474. begin
  475.     kString := numToStr(kScale);
  476.     select [radioButton t:kString+'%']!;
  477.     println "#      Scale -> ",kScale;
  478. end;
  479.  
  480. ##  SetLWSCOptions
  481. ##        Sets options in Page Setup dialog for LWIISC driver.
  482.  
  483. task SetLWSCOptions(kExactImage)
  484. begin
  485.     match [checkBox t:/Exact Bit Images/ s:?kExactChecked];
  486.     wait(1);
  487.     if (kExactImage = true) and (kExactChecked[1] = 0)
  488.         select [checkBox t:/Exact Bit Images/];
  489.     else if (kExactImage = false) and (kExactChecked[1] = 1)
  490.         select [checkBox t:/Exact Bit Images/];
  491.     println "#      Exact Bit Images -> ",kExactImage;
  492. end;
  493.  
  494.